﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using AccountManagement.Entities;

namespace ServiceApp
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        string GetData();

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/users", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<User> GetUsers();

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/userMemberOf/{userName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<Group> GetUserMemberOf(string userName);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetEmployee/{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Employee GetEmployee(string id);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/SaveEmployee", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        bool SaveEmployee(Employee employee);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/UploadFile", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        int UploadFile(FileInformation fileInfo);


        // for Groups
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/groupMemberOf/{groupName}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<Group> GetGroupMemberOf(string groupName);

        // for Groups
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/groups", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        List<Group> AllGroups();
    }

    [DataContract]
    public class FileInformation
    {
        [DataMember]
        public string Name
        {
            get;
            set;
        }

        [DataMember]
        public byte[] Content
        {
            get;
            set;
        }
    }

    [DataContract]
    public class Employee
    {
        [DataMember]
        public int Id
        {
            get;
            set;
        }

        [DataMember]
        public string Name
        {
            get;
            set;
        }
    }
}
